home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / lists / mint / l_1199 / 1007 < prev    next >
Encoding:
Internet Message Format  |  1994-08-27  |  2.1 KB

  1. Subject: Re: Inquiring cttys
  2. Date: Sun, 13 Feb 94 0:29:18 CET
  3. From: Juergen Lock <nox@jelal.north.de>
  4. In-Reply-To: <9402111146.AA08333@math.uni-muenster.de>; from "Julian Reschke" at Feb 11, 94 12:46 pm
  5. Message-Id: <9402122329.AA00137@jelal.north.de>
  6.  
  7. Julian Reschke writes:
  8.  
  9. > A while back, someone (Juergen?) posted a new Fcntl for u:\proc to inquire
  10. > the controlling tty of a process. Please repost that one, because it would
  11. > be very useful for my ps.ttp...
  12.  
  13.  ok you want a patch... :)
  14.  
  15. Index: file.h
  16. @@ -391,6 +391,7 @@
  17.  #define PTRACESTEP    (('P'<< 8) | 10)
  18.  #define PTRACE11    (('P'<< 8) | 11)
  19.  #define PLOADINFO    (('P'<< 8) | 12)
  20. +#define PFSTAT        (('P'<< 8) | 13)
  21.  
  22.  struct ploadinfo {
  23.      /* passed */
  24. Index: procfs.c
  25. @@ -561,11 +561,23 @@
  26.          *((long *)buf) = (long)&p->magic;
  27.          return 0;
  28.      case PBASEADDR:
  29. -        *((long *)buf) = (long)p->base;
  30. +        if (p == rootproc)
  31. +            *((long *)buf) = (long)_base;
  32. +        else
  33. +            *((long *)buf) = (long)p->base;
  34.          return 0;
  35.      case PCTXTSIZE:
  36.          *((long *)buf) = sizeof(CONTEXT);
  37.          return 0;
  38. +    case PFSTAT:
  39. +        {
  40. +        FILEPTR *pf;
  41. +        int pfd = (*(ushort *)buf);
  42. +        if (pfd < MIN_HANDLE || pfd >= MAX_OPEN ||
  43. +            !(pf = p->handle[pfd]))
  44. +            return EIHNDL;
  45. +        return (*pf->fc.fs->getxattr)(&pf->fc, (XATTR *)buf);
  46. +        }
  47.      case PSETFLAGS:
  48.          {
  49.          int newflags = (ushort)(*(long *)buf);
  50.  
  51.  PFSTAT does FSTAT on processes fd passed in first word of stat buffer,
  52. to get the control tty use -1 and then search the `inode' in /dev or
  53. /pipe like in ttyname(),
  54.  
  55.     volatile struct stat sb;
  56.  
  57.     *(short *)&sb = fd;    /* -1 for /dev/tty */
  58.     if (r = Fcntl(procf, &sb, PFSTAT))
  59.         error ...
  60.     find device...
  61.  
  62. (volatile seems necessary because of the gcc Fcntl binding(?), can this be
  63. fixed?)
  64.  
  65.  i also changed PBASEADDR to return the kernels real basepage even
  66. when it unlinked itself out of the chain (see main.c), that should help
  67. stephen read kernel memory easier etc.  (btw your ps doesn't use it now
  68. (ADDR), right? :)
  69.  
  70.  later...
  71.     Juergen
  72. -- 
  73. J"urgen Lock / nox@jelal.north.de / UUCP: ..!uunet!unido!uniol!jelal!nox
  74.                                 ...ohne Gewehr
  75. PGP public key fingerprint =  8A 18 58 54 03 7B FC 12  1F 8B 63 C7 19 27 CF DA 
  76.